package jdbc1;

import java.sql.Date;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Scanner;

public class StudentDaoTest {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		IStudentDao st = new StudentDao();
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");

		System.out.println("请输入一下操作");
		System.out.println("1,查询  2，增加 数据  3.删除数据  4.修改数据  5，数据分页");
		int a = in.nextInt();
		switch (a) {
		case 1: {
			List<Student> list = st.findall();
			for (Object o : list) {
				System.out.println(o);
			}
			break;
		}
		case 2: {
			// 增加
			System.out.println("请输入姓名、电话号码、QQ号、微信号、城市、家庭地址、");
			System.out.println("性别、年级编号(需要进行关联),入学日期,生日,密码");
			String name = in.next();
			String tel = in.next();
			String qq = in.next();
			String wechat = in.next();
			String formcity = in.next();
			String address = in.next();
			String sex = in.next();
			int gradeid = in.nextInt();
			String exam_date = in.next();
			Date birthday = Date.valueOf(in.next());
			// String birthday = in.next();
			String pass = in.next();
			Student s = new Student(name, sex, tel, qq, wechat, gradeid,
					exam_date, formcity, birthday, address, pass);
			int num = st.inster(s);
			System.out.println(num);
			break;
		}
		case 3: {
			// System.out.println("请输入姓名、电话号码、QQ号、微信号、城市、家庭地址、");
			// System.out.println("性别、年级编号(需要进行关联),入学日期,生日,密码 学号");
			// String name = in.next();
			// String tel = in.next();
			// String qq = in.next();
			// String wechat = in.next();
			// String formcity = in.next();
			// String address = in.next();
			// String sex = in.next();
			// int gradeid = in.nextInt();
			// String exam_date = in.next();
			// String birthday = in.next();
			// String pass = in.next();
			// int stuno = in.nextInt();
			// Student s = new Student(stuno, name, sex, tel, qq, wechat,
			// gradeid, exam_date, formcity, birthday, address,
			// pass);
			// int num = st.delete(s);
			// System.out.println(num);
			System.out.println("请输入stuno");
			int stuno = in.nextInt();
			Student s = new Student(stuno);
			int num = st.delete(s);
			System.out.println(num);
			break;

		}
		case 4: {
			System.out.println("请输入姓名、电话号码、QQ号、微信号、城市、家庭地址、");
			System.out.println("性别、年级编号(需要进行关联),入学日期,生日,密码 学号");
			String sname = in.next();
			String tel = in.next();
			String qq = in.next();
			String wechat = in.next();
			String formcity = in.next();
			String address = in.next();
			String sex = in.next();
			int gradeid = in.nextInt();
			String exam_date = in.next();
			Date birthday = Date.valueOf(in.next());
			// Date birthday = Date.valueOf(in.next());
			String pass = in.next();
			int stuno = in.nextInt();
			Student s = new Student(stuno, sname, sex, tel, qq, wechat,
					gradeid, exam_date, formcity, birthday, address, pass);
			int num = st.update(s);
			System.out.println(num);
			break;
		}
		case 5: {
			System.out.println("页数 个数");
			int c = in.nextInt();
			int b = in.nextInt();
			// Student s = new Student();
			List<Student> list = st.paging(c, b);
			for (Object o : list) {
				System.out.println(o);
			}
			break;
		}
		}

	}

}
